use serde_derive::{Serialize, Deserialize};
use lucky::{models::{ProvinceRow as ModelRow}, json::JsonPager};
use sqlx::{postgres::{PgRow}, row::Row};
use crate::common::{Pool, models::BackendModel};

#[derive(Serialize, Deserialize, Debug)]
pub struct Province;

impl BackendModel<ModelRow> for Province {

    const TABLE_NAME: &'static str = "provinces";
    const FIELDS: &'static str = "id, name, code, remark, sort";

    fn get_row_filter(r: &PgRow) -> ModelRow {
        unfold_fields!(r, {
            id => i32,
            name => String,
            code => String,
            remark => String,
            sort => i32,
        })
    }
}

impl Province {

    record_list!();
}
